<?php

/**
 * @name SmsController
 * @author pangee
 * @desc 短信处理功能
 */
class SmsController extends Yaf_Controller_Abstract
{

    public function indexAction()
    {
    }

    /**
     * @return bool
     * 发送短信
     */
    public function sendAction()
    {
        $submit = $this->getRequest()->getQuery("submit", "0");
        if ($submit != "1") {
            echo Common_Request::response(-4001,"请通过正确渠道提交");
            return FALSE;
        }

        // 获取参数
        $uid = $this->getRequest()->getPost("uid", false);
        $contents = $this->getRequest()->getPost("contents", false);
        if (!$uid || !$contents) {
            echo Common_Request::response(-4002,"用户ID、邮件标题、邮件内容均不能为空。");
            return FALSE;
        }

        // 调用Model, 发邮件
        $model = new SmsModel();
        if ($model->send(intval($uid), trim($contents))) {
            echo Common_Request::response(0,"");
        } else {
            echo Common_Request::response($model->errno,$model->errmsg);
        }
        return TRUE;
    }
}
